package kr.saeildamil.androidstudy.ch17;

import kr.saeildamil.androidstudy.R;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;

public class CustomTab extends Activity {
	View mPage1, mPage2, mPage3;
	
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.ch17_customtab);
		
		mPage1 = findViewById(R.id.ch17_customtap_general);
		mPage2 = findViewById(R.id.ch17_customtap_compiler);
		mPage3 = findViewById(R.id.ch17_customtap_opt_linker);
		
		((Button)findViewById(R.id.ch17_customtab_rbtn1)).setOnClickListener(mClickListener);
		((Button)findViewById(R.id.ch17_customtab_rbtn2)).setOnClickListener(mClickListener);
		((Button)findViewById(R.id.ch17_customtab_rbtn3)).setOnClickListener(mClickListener);
	}
	
	OnClickListener mClickListener = new OnClickListener() {
		
		@Override
		public void onClick(View v) {
			switch(v.getId()){
			case R.id.ch17_customtab_rbtn1:
				Changepage(1);
				break;
			case R.id.ch17_customtab_rbtn2:
				Changepage(2);
				break;
			case R.id.ch17_customtab_rbtn3:
				Changepage(3);
				break;
			}
			
			
		}
	};
	private void Changepage(int page) {
		mPage1.setVisibility(View.INVISIBLE);
		mPage2.setVisibility(View.INVISIBLE);
		mPage3.setVisibility(View.INVISIBLE);
		
		switch(page){
		case 1:
			mPage1.setVisibility(View.VISIBLE);
			break;
		case 2:
			mPage2.setVisibility(View.VISIBLE);
			break;
		case 3:
			mPage3.setVisibility(View.VISIBLE);
			break;
		}
		
	}
	
}
